<template>
	<view class="container">
		<!-- 自定义导航栏 -->
		<!-- <view class="custom-nav">
			<view class="nav-content">
				<view class="back" @click="handleBack">
					<text class="iconfont icon-back"></text>
				</view>
				<text class="title">关于我们</text>
			</view>
		</view> -->
		
		<!-- 联系方式列表 -->
		<view class="contact-list">
			<!-- 客服热线 -->
			<view class="contact-item">
				<view class="left">
					<text class="iconfont icon-phone"></text>
					<view class="info">
						<text class="label">客户服务热线</text>
						<text class="value">18171759943</text>
					</view>
				</view>
				<view class="actions">
					<text class="action-btn" @click="handleCall('18171759943')">
						<text class="iconfont icon-phone"></text>
						拨打
					</text>
					<text class="action-btn" @click="handleCopy('18171759943')">
						<text class="iconfont icon-copy"></text>
						复制
					</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
const handleBack = () => {
	uni.navigateBack()
}

// 拨打电话
const handleCall = (phone) => {
    plus.android.requestPermissions(
	["android.permission.CALL_PHONE"], 
	function(resultObj) {
		var result = 0;
		for (var i = 0; i < resultObj.granted.length; i++) {
			var grantedPermission = resultObj.granted[i];
			console.log('已获取的权限：' + grantedPermission);
			result = 1
		}
		for (var i = 0; i < resultObj.deniedPresent.length; i++) {
			var deniedPresentPermission = resultObj.deniedPresent[i];
			console.log('拒绝本次申请的权限：' + deniedPresentPermission);
			result = 0
		}
		for (var i = 0; i < resultObj.deniedAlways.length; i++) {
			var deniedAlwaysPermission = resultObj.deniedAlways[i];
			console.log('永久拒绝申请的权限：' + deniedAlwaysPermission);
			result = -1
		}
		console.log(result);
		if(result == 1){
			uni.makePhoneCall({
				 phoneNumber: phone,//电话号码
				success(ress) {
					console.log("拨打电话成功",ress)
				},
				fail(err) {
					console.log("拨打电话失败",'err')
				}
			});
		}else{
			uni.showToast({
				title:"请开启拨号权限",
				icon:"error",
			})
		}
	},
	function(error) {
		console.log('申请权限错误：' + error.code + " = " + error.message);
	}
);

}

const handleCopy = (text) => {
	uni.setClipboardData({
		data: text,
		success: () => {
			uni.showToast({
				title: '已复制到剪贴板',
				icon: 'success'
			})
		}
	})
}
</script>

<style lang="scss" scoped>
.container {
	min-height: 100vh;
	background-color: #f5f5f5;
	
	.custom-nav {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 100;
		background-color: #fff;
		padding-top: var(--status-bar-height);
		box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
		
		.nav-content {
			position: relative;
			height: 88rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			
			.back {
				position: absolute;
				left: 30rpx;
				top: 50%;
				transform: translateY(-50%);
				padding: 10rpx;
				
				.iconfont {
					font-size: 40rpx;
					color: #333;
				}
			}
			
			.title {
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
			}
		}
	}
	
	.contact-list {
		padding: calc(var(--status-bar-height) + 88rpx + 20rpx) 30rpx 30rpx;
		
		.contact-item {
			background: #fff;
			border-radius: 12rpx;
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 20rpx;
			
			.left {
				display: flex;
				align-items: center;
				
				.iconfont {
					font-size: 40rpx;
					color: #007AFF;
					margin-right: 20rpx;
				}
				
				.info {
					display: flex;
					flex-direction: column;
					
					.label {
						font-size: 28rpx;
						color: #666;
						margin-bottom: 6rpx;
					}
					
					.value {
						font-size: 32rpx;
						color: #333;
						font-weight: bold;
					}
				}
			}
			
			.actions {
				display: flex;
				gap: 20rpx;
				
				.action-btn {
					display: flex;
					align-items: center;
					font-size: 26rpx;
					color: #007AFF;
					padding: 10rpx 20rpx;
					background: rgba(0,122,255,0.1);
					border-radius: 30rpx;
					
					.iconfont {
						font-size: 24rpx;
						margin-right: 6rpx;
					}
					
					&:active {
						opacity: 0.7;
					}
				}
			}
			
			&:active {
				background: #f9f9f9;
			}
		}
	}
}
</style> 